<!--
 * @Author: HeAo
 * @Date: 2021-12-28 09:41:59
 * @LastEditTime: 2021-12-28 10:11:42
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \study\day03\4-ajax.html
 * 别乱动！
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script>
    // 1.实例化连接实例
    let xhr = new XMLHttpRequest()
    // 2.配置请求方法，以及请求目标地址 
    let url = 'https://api.muxiaoguo.cn/api/163reping'
    xhr.open('get', url)
    // 3.发送请求（可以配置请求体参数）
    xhr.send()
    // 4.监听请求状态码的改变，接受响应数据
    xhr.onreadystatechange = function () {
      if (xhr.readyState == 4 && xhr.status == 200) {
        let res = JSON.parse(xhr.responseText)
        console.log(res.data);
      }
    }
  </script>
</head>

<body>

</body>

</html>